package com.nuoniu.sibanyun.controller.erp;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.dto.ErpReportProgrammeSearchDto;
import com.nuoniu.sibanyun.entity.erp.ErpReportDesign;
import com.nuoniu.sibanyun.entity.erp.ErpReportProgramme;
import com.nuoniu.sibanyun.service.erp.IErpReportProgrammeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author baiqiang
 * @since 2021-02-02
 */
@RestController
@RequestMapping("/erp/reportProgramme")
@Api(value = "ERP_报表方案", tags = "ERP_报表方案")
public class ErpReportProgrammeController extends BaseController {

    @Autowired
    private IErpReportProgrammeService erpReportProgrammeService;


    @GetMapping("/getSystemReportProgramme")
    @ApiOperation(value = "查询系统报表方案")
    public HttpResult<List<ErpReportDesign>> getSystemReportProgramme(String reportCode) {
        return HttpResult.ok(erpReportProgrammeService.getSystemReportProgramme(reportCode));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询个人报表方案")
    public HttpResult<List<ErpReportProgramme>> list(ErpReportProgrammeSearchDto erpReportProgrammeSearchDto) {
        return HttpResult.ok(erpReportProgrammeService.listPersonalErpReportProgrammes(erpReportProgrammeSearchDto));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public HttpResult save(@RequestBody ErpReportProgramme erpReportProgramme) {
        erpReportProgrammeService.savePersonalErpReportProgramme(erpReportProgramme);
        return HttpResult.ok();
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除")
    public HttpResult delete(Long id) {
        erpReportProgrammeService.deletePersonalErpReportProgramme(id);
        return HttpResult.ok();
    }

}
